%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/interfaces-relational/commentables"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: Access[8], Access[9], Object[10]<br />2: PgSelect[7]<br />3: PgSelectRows[12]<br />4: __ListTransform[11]"):::bucket
    Bucket1("Bucket 1 (subroutine)<br /><br />ROOT PgSelectSingle{1}ᐸrelational_commentablesᐳ[14]"):::bucket
    Bucket2("Bucket 2 (listItem)<br />Deps: 10<br /><br />ROOT __Item{2}ᐸ11ᐳ[15]"):::bucket
    Bucket3("Bucket 3 (polymorphic)<br />__typename: Lambda[21]<br />Deps: 21, 10, 17"):::bucket
    Bucket4("Bucket 4 (polymorphicPartition)<br />|RelationalPost<br />Deps: 10, 17<br />ᐳRelationalPost<br /><br />1: PgSelectInlineApply[113]<br />2: PgSelect[23]<br />ᐳ: Access[114]<br />3: PgSelectRows[28]<br />ᐳ: 27, 29, 44, 107, 110, 112, 115, 116<br />4: PgSelectRows[52]<br />ᐳ: 51, 53, 54, 76, 94"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|RelationalChecklist<br />Deps: 10, 17<br />ᐳRelationalChecklist<br /><br />1: PgSelectInlineApply[117]<br />2: PgSelect[30]<br />ᐳ: Access[118]<br />3: PgSelectRows[35]<br />ᐳ: 34, 36, 45, 108, 119, 120<br />4: PgSelectRows[60]<br />ᐳ: 59, 61, 62, 82, 100"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|RelationalChecklistItem<br />Deps: 10, 17<br />ᐳRelationalChecklistItem<br /><br />1: PgSelectInlineApply[121]<br />2: PgSelect[37]<br />ᐳ: Access[122]<br />3: PgSelectRows[42]<br />ᐳ: 41, 43, 46, 109, 111, 123, 124<br />4: PgSelectRows[68]<br />ᐳ: 67, 69, 70, 88, 106"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4 & Bucket5 & Bucket6

    %% plan dependencies
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 4"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸrelational_commentablesᐳ<br />More deps:<br />- Object[10]"]]:::plan
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    __ListTransform11[["__ListTransform[11∈0] ➊<br />ᐸeach:7ᐳ<br />More deps:<br />- PgSelectRows[12]"]]:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊<br />Dependents: 2"]]:::plan
    PgSelect7 --> PgSelectRows12
    __Item13[/"__Item[13∈1]<br />ᐸ12ᐳ<br />More deps:<br />- PgSelectRows[12]"\]:::itemplan
    PgSelectSingle14{{"PgSelectSingle[14∈1]<br />ᐸrelational_commentablesᐳ"}}:::plan
    __Item13 --> PgSelectSingle14
    __Item15[/"__Item[15∈2]<br />ᐸ11ᐳ"\]:::itemplan
    __ListTransform11 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈2]<br />ᐸrelational_commentablesᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__relation...les__.”id”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression19
    Lambda21{{"Lambda[21∈2]<br />ᐸrelationalItemTypeNameFromTypeᐳ"}}:::plan
    PgClassExpression19 -->|rejectNull| Lambda21
    PgSelect23[["PgSelect[23∈4]^<br />ᐸrelational_postsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply113["PgSelectInlineApply[113∈4] ➊<br />ᐳRelationalPost"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect23
    PgSelectInlineApply113 --> PgSelect23
    List115{{"List[115∈4]^<br />ᐸ114,29ᐳ"}}:::plan
    Access114{{"Access[114∈4]^<br />ᐸ23.m.joinDetailsFor47ᐳ"}}:::plan
    PgSelectSingle29{{"PgSelectSingle[29∈4]^<br />ᐸrelational_postsᐳ"}}:::plan
    Access114 & PgSelectSingle29 --> List115
    First27{{"First[27∈4]^"}}:::plan
    PgSelectRows28[["PgSelectRows[28∈4]^"]]:::plan
    PgSelectRows28 --> First27
    PgSelect23 --> PgSelectRows28
    First27 --> PgSelectSingle29
    PgClassExpression44{{"PgClassExpression[44∈4]^<br />ᐸ__relation...sts__.”id”ᐳ"}}:::plan
    PgSelectSingle29 --> PgClassExpression44
    First51{{"First[51∈4]^"}}:::plan
    PgSelectRows52[["PgSelectRows[52∈4]^"]]:::plan
    PgSelectRows52 --> First51
    Lambda116{{"Lambda[116∈4]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda116 --> PgSelectRows52
    PgSelectSingle53{{"PgSelectSingle[53∈4]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First51 --> PgSelectSingle53
    PgClassExpression54{{"PgClassExpression[54∈4]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle53 --> PgClassExpression54
    PgClassExpression76{{"PgClassExpression[76∈4]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression54 o--o PgClassExpression76
    PgClassExpression94{{"PgClassExpression[94∈4]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression76 o--o PgClassExpression94
    PgClassExpression107{{"PgClassExpression[107∈4]^<br />ᐸ__relation...__.”title”ᐳ"}}:::plan
    PgClassExpression44 o--o PgClassExpression107
    PgClassExpression110{{"PgClassExpression[110∈4]^<br />ᐸ__relation...scription”ᐳ"}}:::plan
    PgClassExpression107 o--o PgClassExpression110
    PgClassExpression112{{"PgClassExpression[112∈4]^<br />ᐸ__relation...s__.”note”ᐳ"}}:::plan
    PgClassExpression110 o--o PgClassExpression112
    PgSelect23 --> Access114
    List115 --> Lambda116
    PgSelect30[["PgSelect[30∈5]^<br />ᐸrelational_checklistsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply117["PgSelectInlineApply[117∈5] ➊<br />ᐳRelationalChecklist"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect30
    PgSelectInlineApply117 --> PgSelect30
    List119{{"List[119∈5]^<br />ᐸ118,36ᐳ"}}:::plan
    Access118{{"Access[118∈5]^<br />ᐸ30.m.joinDetailsFor55ᐳ"}}:::plan
    PgSelectSingle36{{"PgSelectSingle[36∈5]^<br />ᐸrelational_checklistsᐳ"}}:::plan
    Access118 & PgSelectSingle36 --> List119
    First34{{"First[34∈5]^"}}:::plan
    PgSelectRows35[["PgSelectRows[35∈5]^"]]:::plan
    PgSelectRows35 --> First34
    PgSelect30 --> PgSelectRows35
    First34 --> PgSelectSingle36
    PgClassExpression45{{"PgClassExpression[45∈5]^<br />ᐸ__relation...sts__.”id”ᐳ"}}:::plan
    PgSelectSingle36 --> PgClassExpression45
    First59{{"First[59∈5]^"}}:::plan
    PgSelectRows60[["PgSelectRows[60∈5]^"]]:::plan
    PgSelectRows60 --> First59
    Lambda120{{"Lambda[120∈5]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda120 --> PgSelectRows60
    PgSelectSingle61{{"PgSelectSingle[61∈5]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First59 --> PgSelectSingle61
    PgClassExpression62{{"PgClassExpression[62∈5]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle61 --> PgClassExpression62
    PgClassExpression82{{"PgClassExpression[82∈5]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression62 o--o PgClassExpression82
    PgClassExpression100{{"PgClassExpression[100∈5]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression82 o--o PgClassExpression100
    PgClassExpression108{{"PgClassExpression[108∈5]^<br />ᐸ__relation...__.”title”ᐳ"}}:::plan
    PgClassExpression45 o--o PgClassExpression108
    PgSelect30 --> Access118
    List119 --> Lambda120
    PgSelect37[["PgSelect[37∈6]^<br />ᐸrelational_checklist_itemsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgSelectInlineApply121["PgSelectInlineApply[121∈6] ➊<br />ᐳRelationalChecklistItem"]:::plan
    PgClassExpression17 -->|rejectNull| PgSelect37
    PgSelectInlineApply121 --> PgSelect37
    List123{{"List[123∈6]^<br />ᐸ122,43ᐳ"}}:::plan
    Access122{{"Access[122∈6]^<br />ᐸ37.m.joinDetailsFor63ᐳ"}}:::plan
    PgSelectSingle43{{"PgSelectSingle[43∈6]^<br />ᐸrelational_checklist_itemsᐳ"}}:::plan
    Access122 & PgSelectSingle43 --> List123
    First41{{"First[41∈6]^"}}:::plan
    PgSelectRows42[["PgSelectRows[42∈6]^"]]:::plan
    PgSelectRows42 --> First41
    PgSelect37 --> PgSelectRows42
    First41 --> PgSelectSingle43
    PgClassExpression46{{"PgClassExpression[46∈6]^<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle43 --> PgClassExpression46
    First67{{"First[67∈6]^"}}:::plan
    PgSelectRows68[["PgSelectRows[68∈6]^"]]:::plan
    PgSelectRows68 --> First67
    Lambda124{{"Lambda[124∈6]^<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda124 --> PgSelectRows68
    PgSelectSingle69{{"PgSelectSingle[69∈6]^<br />ᐸrelational_itemsᐳ"}}:::plan
    First67 --> PgSelectSingle69
    PgClassExpression70{{"PgClassExpression[70∈6]^<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle69 --> PgClassExpression70
    PgClassExpression88{{"PgClassExpression[88∈6]^<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgClassExpression70 o--o PgClassExpression88
    PgClassExpression106{{"PgClassExpression[106∈6]^<br />ᐸ__relation...”position”ᐳ"}}:::plan
    PgClassExpression88 o--o PgClassExpression106
    PgClassExpression109{{"PgClassExpression[109∈6]^<br />ᐸ__relation...scription”ᐳ"}}:::plan
    PgClassExpression46 o--o PgClassExpression109
    PgClassExpression111{{"PgClassExpression[111∈6]^<br />ᐸ__relation...s__.”note”ᐳ"}}:::plan
    PgClassExpression109 o--o PgClassExpression111
    PgSelect37 --> Access122
    List123 --> Lambda124

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,__ListTransform11,PgSelectRows12 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item13,PgSelectSingle14 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,__Item15,PgSelectSingle16,PgClassExpression17,PgClassExpression19,Lambda21 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelect23,First27,PgSelectRows28,PgSelectSingle29,PgClassExpression44,First51,PgSelectRows52,PgSelectSingle53,PgClassExpression54,PgClassExpression76,PgClassExpression94,PgClassExpression107,PgClassExpression110,PgClassExpression112,PgSelectInlineApply113,Access114,List115,Lambda116 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgSelect30,First34,PgSelectRows35,PgSelectSingle36,PgClassExpression45,First59,PgSelectRows60,PgSelectSingle61,PgClassExpression62,PgClassExpression82,PgClassExpression100,PgClassExpression108,PgSelectInlineApply117,Access118,List119,Lambda120 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgSelect37,First41,PgSelectRows42,PgSelectSingle43,PgClassExpression46,First67,PgSelectRows68,PgSelectSingle69,PgClassExpression70,PgClassExpression88,PgClassExpression106,PgClassExpression109,PgClassExpression111,PgSelectInlineApply121,Access122,List123,Lambda124 bucket6

